Fix timezones in psitrex track format. From Mark.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 21 Oct 2003 21:25:16 +0000 (21:25 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 21 Oct 2003 21:25:16 +0000 (21:25 +0000)
gpsbabel/psitrex.c
gpsbabel/testo

index b47e561a9fd5bdfc1a811f20953280d320130494..2bb1a1482df201b1be2facaaa50c7fffba58bcd6 100755 (executable)
@@ -26,6 +26,8 @@
 #include "garmin_tables.h"
 #include <ctype.h>
 
+#define MYNAME "PSITREX" 
+
 typedef enum {
        ltrimEOL = 1 ,          /* skip spaces & tabs to start; ends on EOL */
        EOL,                            /* don't skip spaces and tabs to start; end on EOL */
@@ -48,8 +50,6 @@ static void *mkshort_handle;
    0 = in the middle of writing out track datapoints, so don't write a header */
 static int     psit_track_state = 2;
 
-#define MYNAME "MAPSOURCE" 
-
 static char psit_current_token[256];
 
 char *snlen;
@@ -583,17 +583,25 @@ psit_track_r(FILE *psit_file, route_head **trk)
                        }
 
                        /* date portion of the date time DD/MM/YY */
-                       psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace);
-                       sscanf(psit_current_token, "%02d/%02d/%02d", &(tmTime.tm_mday) , &(tmTime.tm_mon), &(tmTime.tm_year));
-                       tmTime.tm_year += (tmTime.tm_year > 50 ? 0 : 100);              /* years are less 1900 in the tm struct */
-                       tmTime.tm_mon--;                                                                                /* months are 0 to 11 in the tm struct */
-
+                       psit_getToken(psit_file, psit_current_token,
+                                       sizeof(psit_current_token), whitespace);
+                       sscanf(psit_current_token, "%02d/%02d/%02d", 
+                               &(tmTime.tm_mday) , &(tmTime.tm_mon), 
+                               &(tmTime.tm_year));
+
+                       /* years are less 1900 in the tm struct */
+                       tmTime.tm_year += (tmTime.tm_year > 50 ? 0 : 100);              
+                       /* months are 0 to 11 in the tm struct */
+                       tmTime.tm_mon--;                                                                                
                        /* time portion of the date time hh:mm:ss */
-                       psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
-                       sscanf(psit_current_token, "%02d:%02d:%02d", &(tmTime.tm_hour) , &(tmTime.tm_min), &(tmTime.tm_sec));
+                       psit_getToken(psit_file,psit_current_token,
+                                       sizeof(psit_current_token), wscomma);
+                       sscanf(psit_current_token, "%02d:%02d:%02d", 
+                                       &(tmTime.tm_hour) , &(tmTime.tm_min), 
+                                       &(tmTime.tm_sec));
 
                        tmTime.tm_isdst = 0;
-                       dateTime = mktime(&tmTime);
+                       dateTime = mktime(&tmTime) + get_tz_offset();
 
                        psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace);
 
@@ -669,7 +677,6 @@ psit_trackhdr_w(FILE *psit_file, const route_head *trk)
                }
        }
        psit_track_state = 1;
-
 }
 
 static void
@@ -687,7 +694,7 @@ static void
 psit_trackdatapoint_w(FILE *psit_file, const waypoint *wpt)
 {
        time_t  t = wpt->creation_time;
-       struct tm *tmTime = gmtime(&(wpt->creation_time));
+       struct tm *tmTime = gmtime(&t);
 
        double  psit_altitude = wpt->position.altitude.altitude_meters;
        double  psit_proximity = unknown_alt;
index 9bb209a40e95ee24b36c9dd1c21f24275f50d7e5..8741ce67afd9c88ede17e1cef23386545cd3d7be 100755 (executable)
@@ -392,8 +392,7 @@ compare reference/mps-empty.mps ${TMPDIR}/psit-rt.mps
 rm -f ${TMPDIR}/psit-tt.txt ${TMPDIR}/psit-tt.mps
 ${PNAME} -t -i psitrex -f reference/track/psittrks.txt -o mapsource -F ${TMPDIR}/psit-tt.mps
 ${PNAME} -t -i mapsource -f ${TMPDIR}/psit-tt.mps -o psitrex -F ${TMPDIR}/psit-tt.txt
-echo skipping psitrex track test for now
-# compare reference/track/psittrks.txt ${TMPDIR}/psit-tt.txt
+compare reference/track/psittrks.txt ${TMPDIR}/psit-tt.txt
 
 # Now test correct "empty" handling - ask for waypoints when there aren't any
 # Uses mapsource as the empty handling for this has already happened above